package com.atguigu.boot.config;

import com.atguigu.boot.bean.Car;
import com.atguigu.boot.bean.Pet;
import com.atguigu.boot.bean.User;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;

/**
 * @author anan
 * @create 2021-08-10 21:44
 */


@ImportResource("classpath:beans.xml")
@Import({User.class})
@Configuration  //告诉spring这是一个配置类
@EnableConfigurationProperties(Car.class)
public class MyConfig {

    @ConditionalOnBean(name = "tom01")
    @Bean
    public User user01(){
        return new User("zhangsan", 18);
    }

    //@Bean("tom01")
    public Pet tomcat(){
        return new Pet("tomcat");
    }
}
